﻿using System;
using System.Text;

namespace DHelpers.ExtensionsHelper
{
    public static class ExtensionsStringHelper
    {
        public static string GetExceptionMessage(this Exception ex)
        {
            if (ex.InnerException != null) { ex = ex.InnerException; }
            var sb = new StringBuilder();
            sb.AppendLine(string.Format("Message: {0}", ex.Message));
            sb.AppendLine(string.Format("Source: {0}", ex.Source));
            sb.AppendLine(string.Format("Stack Trace: {0}", ex.StackTrace));
            sb.AppendLine(string.Format("TargetSite: {0}", ex.TargetSite));
            return ex.ToString();
        }
    }
}
